<template>
  <!--右侧修改密码信息栏-->
  <div class="container-account">
    <div class="account-head">
      <span class="account-shield">100</span>
      <span class="account-desc no-risk">无风险</span>
    </div>
    <div class="accout-body" style="position: relative;min-height: 370px;">
      <span class="accout-body-title">修改密码</span>

      <el-form ref="form" :model="user" :rules="rules"
               label-width="80px" style="top: 22%;position: absolute;text-align: center;width: 50%;left: 24%;"
      >
        <el-form-item label="旧密码" prop="oldPassword" style="margin-bottom: 30px;">
          <el-input style="margin-left: 10px" v-model="user.oldPassword" placeholder="请输入旧密码" type="password" show-password/>
        </el-form-item>
        <el-form-item label="新密码" prop="newPassword" style="margin-bottom: 30px;">
          <el-input style="margin-left: 10px" v-model="user.newPassword" placeholder="请输入新密码" type="password" show-password/>
        </el-form-item>
        <el-form-item label="确认密码" prop="confirmPassword" style="margin-bottom: 30px;">
          <el-input style="margin-left: 10px" v-model="user.confirmPassword" placeholder="请确认密码" type="password" show-password/>
        </el-form-item>
        <el-form-item>
          <el-button  style="width: 30%;margin-left: 10px" type="primary" @click="submit">确认</el-button>
        </el-form-item>
      </el-form>

      <!--      <div class="acc_pass_con">
              <ul class="acc_pass_list">
                <li>
                  <label>输入旧密码：</label>
                  <input type="password" name="password"
                         placeholder="请输入旧密码"
                         autocomplete="off" validate="true"
                         data-rule="['password']"
                         oncopy="return false" class="inpt"
                  >
                  <span for="icon-password" class="visible_icon">
                          <svg aria-hidden="true" class="icon">
                            <use xlink:href="#csdnc-m-passwords-invisible"></use>
                          </svg>
                        </span>
                  <div class="control-col-strong hide"><p></p></div>
                </li>
                <li>
                  <label>输入新密码：</label>
                  <input type="password" name="password" id="password"
                         placeholder="11-20位数字和字母组合"
                         autocomplete="off" validate="true"
                         data-rule="['password']"
                         oncopy="return false" class="inpt"
                  >
                  <span for="icon-password" class="visible_icon">
                          <svg aria-hidden="true" class="icon">
                            <use xlink:href="#csdnc-m-passwords-invisible"></use>
                          </svg>
                        </span>
                  <div class="control-col-strong hide"><p></p></div>
                </li>
                <li><label>确认新密码：</label>
                  <input id="confirmPwd"
                         type="password" placeholder="确认新密码"
                         autocomplete="off"
                         oncopy="return false" class="inpt"
                  >
                  <span class="visible_icon">
                          <svg aria-hidden="true" class="icon">
                            <use xlink:href="#csdnc-m-passwords-invisible"></use>
                          </svg>
                        </span>
                </li>
                <li class="error_tips hide"></li>
                <li class="acc_pass_b">
                  <button disabled="disabled" class="confirm_btn confirm_disable">确认</button>
                </li>
              </ul>
            </div>-->
      <!--      <ul>
              <li class="accout-body-item">
                <span><span>密</span><span>码</span></span>
                <p>
                  <a href="#/user-center/account/password" class="">修改密码</a>
                </p>
              </li>
              <li class="accout-body-item">
                <span><span>手</span><span>机</span></span>
                <p>
                  <span>151****9349</span>
                  <a href="#/user-center/account/cellphone" class="">修改手机</a>
                </p>
              </li>
              <li class="accout-body-item">
                <span><span>邮</span><span>箱</span></span>
                <p>
                  <span>15***@163.com</span>
                  <a href="#/user-center/account/email" class="">修改邮箱</a>
                </p>
              </li>
              <li class="accout-body-item"><span>登录记录</span>
                <p>
                  <a href="#/user-center/account/log" class="">查看记录</a>
                </p>
              </li>
            </ul>-->
    </div>
  </div>
</template>

<script>
import { updateUserPwd } from '@/api/user'

export default {
  name: 'resetPwd',
  data() {
    const equalToPassword = (rule, value, callback) => {
      if (this.user.newPassword !== value) {
        callback(new Error('两次输入的密码不一致'))
      } else {
        callback()
      }
    }
    return {
      test: '1test',
      user: {
        oldPassword: undefined,
        newPassword: undefined,
        confirmPassword: undefined
      },
      // 表单校验
      rules: {
        oldPassword: [
          { required: true, message: '旧密码不能为空', trigger: 'blur' }
        ],
        newPassword: [
          { required: true, message: '新密码不能为空', trigger: 'blur' },
          { min: 6, max: 16, message: '长度在 6 到 16 个字符', trigger: 'blur' }
        ],
        confirmPassword: [
          { required: true, message: '确认密码不能为空', trigger: 'blur' },
          { required: true, validator: equalToPassword, trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    submit() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          updateUserPwd(this.user.oldPassword, this.user.newPassword).then(response => {
              if (response.code === 200) {
                this.msgSuccess('修改成功')
              } else {
                this.msgError(response.msg)
              }
            }
          )
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
#app_main {
  .el-form-item__error {
    color: #f56c6c;
    font-size: 12px;
    line-height: 1;
    padding-top: 4px;
    position: absolute;
    top: 100%;
    left: 0;
  }

  input[type=number] {
    -moz-appearance: textfield;
  }

  input[type=number]::-webkit-inner-spin-button,
  input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  .el-radio.is-bordered {
    padding: 12px 20px 0 10px;
    border-radius: 4px;
    border: 1px solid #DCDFE6;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    height: 40px
  }

  .el-radio.is-bordered.is-checked {
    border-color: #409EFF
  }

  .el-radio.is-bordered.is-disabled {
    cursor: not-allowed;
    border-color: #EBEEF5
  }

  .el-radio__input.is-disabled .el-radio__inner, .el-radio__input.is-disabled.is-checked .el-radio__inner {
    background-color: #F5F7FA;
    border-color: #E4E7ED
  }

  .el-radio.is-bordered + .el-radio.is-bordered {
    margin-left: 10px
  }

  .el-input__icon {
    height: 100%;
    width: 25px;
    text-align: center;
    -webkit-transition: all .3s;
    transition: all .3s;
    line-height: 40px
  }

  .el-input__icon:after {
    content: '';
    height: 100%;
    width: 0;
    display: inline-block;
    vertical-align: middle
  }

  .el-input.is-disabled .el-input__icon {
    cursor: not-allowed
  }

  .el-input--medium .el-input__icon {
    line-height: 36px
  }

  .el-input--small .el-input__icon {
    line-height: 32px
  }

  .el-input--mini .el-input__icon {
    line-height: 28px
  }

  .el-transfer-panel__filter .el-input__icon {
    margin-left: 5px
  }

  .el-form--label-left .el-form-item__label {
    text-align: left
  }

  .el-form--label-top .el-form-item__label {
    float: none;
    display: inline-block;
    text-align: left;
    padding: 0 0 10px
  }

  .el-form-item__label {
    text-align: right;
    vertical-align: middle;
    float: left;
    font-size: 14px;
    color: #606266;
    line-height: 40px;
    padding: 0 12px 0 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box
  }

  .container.container-fixed .container-left {
    position: fixed;
    top: 58px;
  }

  .container.container-fixed .user-center-floor {
    position: fixed;
    top: 58px;
  }

  .container {
    position: relative;
    width: auto;
    min-width: 896px;
    min-height: 800px;
    background: transparent;
    margin: 10px auto 20px auto;
  }

  .container .container-left {
    position: absolute;
    width: 190px;
    top: 0;
    float: left;
    background: #fff;
  }

  .container .container-left ul {
    width: 100%;
    list-style: none;
    font-size: 14px;
    padding: 8px 0;
  }

  /*.container .container-left ul li:last-child {
    border-top: 1px solid #f0f0f5;
    padding-top: 8px;
    margin-top: 8px;
  }

  .container .container-left ul li:last-child a {
    position: relative;
  }

  .container .container-left ul li:last-child a i {
    position: absolute;
    top: 50%;
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    right: 16px;
  }*/

  .container .container-left ul a {
    display: block;
    width: 100%;
    height: 48px;
    line-height: 48px;
    text-align: center;
    color: #555666;
  }

  .container .container-left ul a:hover {
    background: #f0f0f5;
    font-weight: 500;
    color: #222226;
  }

  .container .container-left ul a:hover i {
    color: #222226;
  }

  .container .container-left .router-link-active {
    font-weight: 500;
    color: #222226;
    background: #f0f0f5;
  }

  .container .container-left .router-link-active a {
    color: #222226;
  }

  .container .container-left .router-link-active a i {
    color: #222226;
  }

  .container .container-right {
    min-width: 1000px;
    margin-left: 200px;
    min-height: 800px;
  }

  .container .container-right .user-account-content {
    padding: 16px;
    background: #fff;
  }

  .container .container-right .collection {
    width: 1000px;
    background: #fff;
  }

  .container-account {
    width: 1000px;
  }

  .container-account .middle-risk,
  .container-account background #FF991F,
  .container-account .no-risk {
    background: #ff991f;
  }

  .container-account .account-head {
    width: 100%;
    height: 208px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    padding-top: 24px;
    margin-bottom: 10px;
    background: url("../../assets/images/user/pwd.png") no-repeat center center;
    background-size: contain;
    font-size: 12px;
    color: #555666;
    text-align: center;
  }

  .container-account .account-head .account-shield {
    display: block;
    width: 83px;
    height: 100px;
    line-height: 100px;
    margin: auto;
    background: url("../../assets/images/user/anquan.png") no-repeat center center;
    background-size: cover;
    color: #fff;
    font-size: 40px;
  }

  .container-account .account-head .account-desc {
    display: inline-block;
    min-width: 40px;
    padding: 0 8px;
    height: 20px;
    line-height: 20px;
    margin: 8px auto;
    background: #fc1944;
    border-radius: 12px;
    color: #fff;
  }

  .container-account .account-head .account-suggest {
    height: 24px;
    line-height: 24px;
  }

  .container-account .account-head .account-suggest span {
    color: #222226;
    font-weight: 500;
  }

  .container-account .accout-body {
    width: 100%;
    padding: 24px 16px 0 16px;
    min-height: 200px;
    background: #fff;
    font-size: 14px;
  }

  .container-account .accout-body .accout-body-title {
    min-width: 72px;
    height: 24px;
    font-size: 18px;
    font-weight: 600;
    color: #2e2e2e;
    line-height: 24px;
  }

  .container-account .accout-body .accout-body-item {
    height: 72px;
    padding: 32px 0 16px 0;
    color: #555666;
  }

  .container-account .accout-body .accout-body-item > span {
    float: left;
    width: 56px;
    height: 24px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    padding-left: 16px;
    -webkit-box-sizing: content-box;
    box-sizing: content-box;
  }

  .container-account .accout-body .accout-body-item > p {
    float: left;
    text-align: right;
    width: calc(100% - 72px);
    color: #222226;
  }

  .container-account .accout-body .accout-body-item > p a {
    display: inline-block;
    min-width: 56px;
    margin-left: 32px;
    color: #1989fa;
  }

  .container-account .accout-body .accout-body-item + .accout-body-item {
    border-top: 1px solid #f0f0f5;
  }


  /*# sourceMappingURL=src/pages/user-center/account/account.css.map */
  .container-draw {
    background: #fff;
    min-height: 770px;
  }

  .container-draw .head-tabs {
    height: 48px;
    width: 100%;
    background: #FFF;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    border-bottom: 1px solid #F0F0F2;
    padding-left: 24px;
  }

  .container-draw .head-tabs .head-tab-item {
    height: 100%;
    line-height: 48px;
    text-align: center;
    color: #555666;
    font-size: 14px;
    cursor: pointer;
    position: relative;
    margin-right: 48px;
  }

  .container-draw .head-tabs .active {
    font-weight: 500;
    color: #222226;
  }

  .container-draw .head-tabs .active:before {
    content: '';
    width: 24px;
    height: 2px;
    background: #1C1D30;
    border-radius: 1px;
    position: absolute;
    bottom: -1px;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
  }

  .container-draw .contain {
    padding-top: 0;
  }

  .acc_pass_con {
    padding: 28px 0 30px;
  }

  .acc_pass_con .acc_pass_list {
    width: 360px;
    margin: 0 auto;
  }

  .acc_pass_con .acc_pass_list li {
    position: relative;
    margin-bottom: 8px;
    font-size: 0;
  }

  .acc_pass_con .acc_pass_list li label,
  .acc_pass_con .acc_pass_list li input {
    display: inline-block;
    vertical-align: middle;
  }

  .acc_pass_con .acc_pass_list li label {
    width: 100px;
    text-align: right;
    font-size: 14px;
    color: #4d4d4d;
  }

  .acc_pass_con .acc_pass_list li input {
    width: 252px;
    height: 32px;
    line-height: 30px;
    margin-left: 8px;
    border: solid 1px #ccc;
    border-radius: 4px;
    padding: 0 8px;
    font-size: 14px;
    color: #4d4d4d;
  }

  .acc_pass_con .acc_pass_list li .form-control-pwd {
    position: absolute;
    left: 0;
    height: 0;
    opacity: 0;
    z-index: -1;
  }

  .acc_pass_con .acc_pass_list li .error_red {
    background: #fde3e4;
    border-color: #e33e33;
  }

  .acc_pass_con .acc_pass_list li .confirm_btn {
    width: 80px;
    height: 36px;
    line-height: 34px;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
  }

  .acc_pass_con .acc_pass_list li .confirm_primary {
    color: #fff;
    background: #e33e33;
    border: solid 1px #e33e33;
    cursor: pointer;
  }

  .acc_pass_con .acc_pass_list li .confirm_disable {
    color: #4d4d4d;
    background: #f5f5f5;
    border: solid 1px #f5f5f5;
    cursor: default;
    color: #999;
  }

  .acc_pass_con .acc_pass_list li .visible_icon {
    position: absolute;
    right: 10px;
    top: 8px;
    font-size: 16px;
    color: #999;
    cursor: pointer;
  }

  .acc_pass_con .acc_pass_list li .control-col-strong {
    position: absolute;
    width: 100%;
    left: 102%;
    top: 3px;
  }

  .acc_pass_con .acc_pass_list li .control-col-strong .control-line {
    display: inline-block;
    height: 2px;
    width: 32px;
    margin: 0 1px;
    background: #e0e0e0;
  }

  .acc_pass_con .acc_pass_list li .control-col-strong .danger {
    background: #f21f2b;
  }

  .acc_pass_con .acc_pass_list li .control-col-strong .warning {
    background: #ffc275;
  }

  .acc_pass_con .acc_pass_list li .control-col-strong .success {
    background: #86ca5e;
  }

  .acc_pass_con .acc_pass_list li .control-col-strong p {
    font-size: 14px;
    color: #4d4d4d;
    margin-top: 10px;
  }

  .acc_pass_con .acc_pass_list li .hide {
    display: none;
  }

  .acc_pass_con .acc_pass_list .acc_pass_b {
    padding: 20px 0 0 108px;
  }

  .acc_pass_con .acc_pass_list .error_tips {
    font-size: 14px;
    color: #d0021b;
    padding-left: 108px;
  }

  .hide {
    display: none;
  }
}
</style>
<style scoped>
/deep/ .el-form-item__error{
  left: 10px;
}
</style>
